﻿@using ACGN.MVC.Models.Productss;
@model ProductViewModel
<form class="layui-form" id="frmAdd">
	<div class="layui-form layuimini-form"style="border: 1px dashed; margin: 50px 50px 50px 50px; padding: 20px 20px 20px; ">
		<div class="layui-form-item">
			<label class="layui-form-label" asp-for="PName">
			</label>
			<div class="layui-input-block">
				<input type="text" asp-for="PName" required lay-verify="title" autocomplete="off" class="layui-input">
				<span asp-validation-for="PName" style="color: #F56C6C"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label" asp-for="ProTypeId">
			</label>
			<div class="layui-input-block">
				<select asp-for="ProTypeId" asp-items="@ViewBag.ProTypeList">
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label" asp-for="Label">
			</label>
			<div class="layui-input-block">
				<input type="text" asp-for="Label" required lay-verify="title" autocomplete="off" class="layui-input">
				<span asp-validation-for="Label" style="color: #F56C6C"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label" asp-for="Author">
			</label>
			<div class="layui-input-block">
				<input type="text" asp-for="Author" required lay-verify="title" autocomplete="off" class="layui-input">
				<span asp-validation-for="Author" style="color: #F56C6C"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label" asp-for="PIntroduce">
			</label>
			<div class="layui-input-block">
				<input type="text" asp-for="PIntroduce" required lay-verify="title" autocomplete="off" class="layui-input">
				<span asp-validation-for="PIntroduce" style="color: #F56C6C"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>

</form>
@section Scripts{
	<script>
            layui.use(['form'], function () {
                var form = layui.form,
                    layer = layui.layer,
                    $ = layui.$;
                //监听提交事件sumbmit,*表示那个提交按钮，过滤器名
                form.on('submit(saveBtn)', function (data) {
                    var str = $("#frmAdd").serialize();//表单序列化
                    console.log(str);
                    //$.post(地址,向服务器传的参数,回调函数,返回值类型)
					$.post("/Admin/Product/AddPro", str, function (re) {

                        parent.layer.msg("添加成功");//parent父窗体
                        parent.layui.$("#btnSearch").click();//调用你窗体中的查询按钮的单击事件实现，数据刷新
                        //当你在iframe页面关闭自身时
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, "text");
                    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
                });
            });
	</script>
}
